﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DBUtility;
using System.Data.SqlClient;

public partial class BasicBase_SocLinke_SortStat : System.Web.UI.Page
{
    public String rs = "";
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        DataTable dt;
        SQLHelper db = new SQLHelper();
        if (PublicFunction.GetRequstForm(Request, "quan") == "1")
        {
            String depid = PublicFunction.GetRequstForm(Request, "dep");
            SqlParameter[] parameters = {
                    new SqlParameter("@depid", SqlDbType.VarChar, 7)
                };
            if (depid == "1300000")
            {

                parameters[0].Value = "";
                dt = db.GetDatatableProcExcut("SocStatSort", parameters);
            }
            else
            {
                parameters[0].Value = PublicFunction.GetRequstForm(Request, "dep").Substring(0, 4);
                dt = db.GetDatatableProcExcut("SocStatSort", parameters);
            }
        }
        else
        {
            String depid = PublicFunction.GetRequstForm(Request, "dep");
            SqlParameter[] parameters = {
                    new SqlParameter("@depid", SqlDbType.VarChar, 7)
                };
            parameters[0].Value = PublicFunction.GetRequstForm(Request, "dep");
            dt = db.GetDatatableProcExcut("SocStatSort", parameters);
        }
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            rs += "<tr class=\"grid_item\">"+
                    "<td  height=\"25\" width=\"160\" align=\"left\">"+dt.Rows[i][0].ToString()+"</td>"+
                    "<td align=\"left\">" + dt.Rows[i][2].ToString() + "</td>" +
                  "</tr>";
        }
    }
    public String GetDepartmentid()
    {
        SQLHelper db = new SQLHelper();
        String dep = db.GetDataTableBySqlStr("SELECT DepartmentID  FROM [Account_Users] where userid='" + Context.User.Identity.Name + "'").Rows[0][0].ToString();
        if (dep.Substring(4, 1) == "0")
            return dep.Substring(0, 4) + "000";
        else
            return dep;
    }
}
